package com.ferenc.hutool.util;

import cn.hutool.core.util.RuntimeUtil;

import java.io.IOException;
import java.util.List;

/**
 * TODO
 *
 * @author <a href="mailto:ferenc.zeng@gmail.com">Ferenc Zeng</a>
 * @since 2022-01-11
 */
public class TestUtils {

    public static void main(String[] args) throws IOException {

        RuntimeUtil.exec("cd /Users/zengxiangfei");
//        String ls = RuntimeUtil.execForStr("cd /Users/zengxiangfei;ls");

//        System.out.println(ls);

//        String result = RuntimeUtil.execForStr("awk -F '\\|+\\|' '$1!~/编码/{print $1}' test.txt");
//        System.out.println(result);

        Process sh = Runtime.getRuntime().exec(new String[]{"sh", "-c", "awk -F '\\\\|\\\\+\\\\|' '$1!~/编码/{print $1}' test.txt|sort -n|uniq -c|wc -l"});
        String result1 = RuntimeUtil.getResult(sh);
        System.out.println(result1.trim());


        List<String> sh1 = RuntimeUtil.execForLines("sh", "-c", "awk -F '\\\\|\\\\+\\\\|' '$1!~/编码/{print $1}' test.txt");

        System.out.println(sh1.size() + ": " +  sh1.toString());


    }
}
